package net.zjitc.servlet.product;

import net.zjitc.domain.Product;
import net.zjitc.service.ProductService;
import net.zjitc.service.impl.ProduceServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by Administrator on 2017/10/26.
 */
@WebServlet(name = "SearchProductServlet",urlPatterns = "/searchProductServlet")
public class SearchProductServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String condition = request.getParameter("condition");
        //有了条件，就可以查询
        ProductService service = new ProduceServiceImpl();
        List<Product> list = service.findByCondition(condition);
        //要给页面显示
        request.setAttribute("list",list);
        request.getRequestDispatcher("/product/productList.jsp").forward(request,response);
    }
}
